package service

import (
	StreamHubDto "vrcm/src/vrcm/app/admin/service/dto/stream_hub"
	"vrcm/src/vrcm/common/service"
)

type CommonService struct {
	service.Service
}

func (c CommonService) GenerateStreamHubReq(sources []StreamHubDto.Source, outs []StreamHubDto.Target, tenantId string, name string, inputFormat string, inputType string, delayTime int) *StreamHubDto.StreamHubReq {
	req := &StreamHubDto.StreamHubReq{}
	req.Name = name
	req.Type = "live"
	req.TenantId = tenantId
	req.Description = ""
	req.Input = StreamHubDto.Input{
		Format: inputFormat,
		Active: 0,
		Policy: StreamHubDto.Policy{
			Mode: "manual",
		},
		Type:    inputType,
		Sources: sources,
	}

	delay := StreamHubDto.Delay{
		Enable:   "no",
		Duration: 10,
	}
	if delayTime > 0 {
		delay.Enable = "yes"
		delay.Duration = delayTime
	}
	req.Output = StreamHubDto.Output{
		Targets: outs,
		Delay:   delay,
		Acl:     StreamHubDto.Acl{},
	}
	return req
}
